package app.view.component.effect 
{
	import app.facade.App;
	import com.greensock.TweenLite;
	import com.temple.core.CoreMovieClip;
	import flash.display.DisplayObject;
	import flash.events.Event;
	/**
	 * ...
	 * @author PHANCUONG87
	 */
	public class Effect extends CoreMovieClip
	{
		
		public function Effect(){
			addEventListener(Event.ADDED_TO_STAGE, onInital);
		}
		public function onInital(evt:Event):void {
			stage.addEventListener( Event.RESIZE, onResize );	
			onResize(evt);
		}
		public function onResize(evt:Event):void {
			x = Math.round(stage.stageWidth / 2);
			y = Math.round(stage.stageHeight / 2);
		}
		
		public function showBigWin(onComplete:Function = null):void {
			sendNotification(App.SHOW_BACK_SHADER);
			var eff:EBigWin = new EBigWin();
			eff.gotoAndStop(0);
			this.addChild(eff);
			TweenLite.to(eff, 2, {frameLabel:"stop",onComplete:onCompeteEffect, onCompleteParams:[onComplete,eff]});
			
		}
		
		public function showWin(onComplete:Function = null):void {
			sendNotification(App.SHOW_BACK_SHADER);
			var eff:EWin = new EWin();
			eff.gotoAndStop(0);
			this.addChild(eff);
			TweenLite.to(eff, 2, {frameLabel:"stop",onComplete:onCompeteEffect, onCompleteParams:[onComplete,eff]});
			
		}
		
		public function onCompeteEffect(onComplete:Function, eff:EBigWin):void {
			if (eff.parent) {
				eff.parent.removeChild(eff);
				eff = null;
				sendNotification(App.HIDE_BACK_SHADER);
			}
			if (onComplete != null) onComplete();
		}
		
	}

}